from common.constants import *

ERROR_AUTHENTICATION_PARAM = 4950  # 缺少签名参数
ERROR_AUTHENTICATION_TIMESTAMP_EXPIRE = 4951  # 签名时间戳已过期
ERROR_AUTHENTICATION_SIGNATURE_INVALID = 4952  # 签名错误
ERROR_AUTHENTICATION_APPID_INVALID = 4953  # 无效appid
ERROR_AUTHENTICATION_TOKEN_EMPTY = 4954  # token不能为空
ERROR_AUTHENTICATION_ACCOUNT_NOT_FOUND = 4955  # 未找到令牌对应的账号
ERROR_AUTHENTICATION_TOKEN_EXPIRED = 4956  # 令牌过期
ERROR_AUTHENTICATION_TOKEN_ERROR = 4957  # 令牌发生未知错误

AUTHENTICATION_ERROR_TABLE = Choices(
    (ERROR_AUTHENTICATION_PARAM, "4950 缺少签名参数"),
    (ERROR_AUTHENTICATION_TIMESTAMP_EXPIRE, "4951 签名时间戳已过期"),
    (ERROR_AUTHENTICATION_SIGNATURE_INVALID, "4952 签名错误"),
    (ERROR_AUTHENTICATION_APPID_INVALID, "4953 无效appid"),
    (ERROR_AUTHENTICATION_TOKEN_EMPTY, "4954 token不能为空"),
    (ERROR_AUTHENTICATION_ACCOUNT_NOT_FOUND, "4955 未找到令牌对应的账号"),
    (ERROR_AUTHENTICATION_TOKEN_EXPIRED, "4956 令牌过期"),
    (ERROR_AUTHENTICATION_TOKEN_ERROR, "4957 令牌发生未知错误")
)

ERROR_SERIAL_INVALID = 4091  # 无效序列号
ERROR_SERIAL_EXPIRE = 4092  # 序列号过期
ERROR_MACHINE_CODE_INVALID = 4093  # 无效机器码
ERROR_SERIAL_REVOKE_COUNT = 4094  # 序列号吊销次数限制
ERROR_CERT_EXPIRE = 4095  # 无效证书
ERROR_MACHINE_INFO_INVALID = 4096  # 无效机器信息
ERROR_CERT_RENEWAL_TIME = 4097  # 未到续期时间
ERROR_RAW_MACHINE_INFO_PARSE_FAIL = 4098  # 原始机器信息解析失败
ERROR_TRAIN_MODEL_NOT_FOUND = 4099  # 未找到此店铺下的训练模型文件
ERROR_TS_GENERATE_FAIL = 4100  # TS文件生成失败
ERROR_CERT_GENERATE_FAIL = 4101  # 证书生成失败, 请检查机器码
ERROR_CERT_RENEWAL_FAIL = 4102  # 证书续期失败, 请检查机器码
ERROR_SERIAL_DISABLE = 4103  # 序列号吊销次数过多导致禁用
ERROR_SERIAL_DECRY_FAILED = 4104  # 序列号解密失败
ERROR_SERIAL_BATCH_NOT_FOUND = 4105  # 未找到对应的序列号批次
ERROR_SERIAL_DEVICE_NOT_FOUND = 4106  # 查询不到对应的设备-序列号关联数据
ERROR_DEVICE_SERVICE_NOT_EXPIRE = 4107  # 设备服务未到期, 无法再次激活, 请走续期接口
ERROR_RESELLER_FORBIDDEN = 4108  # 经销商被禁用

ERROR_TABLE = Choices(
    (ERROR_SERIAL_INVALID, "4091 无效序列号"),
    (ERROR_SERIAL_EXPIRE, "4092 序列号过期"),
    (ERROR_MACHINE_CODE_INVALID, "4093 无效机器码"),
    (ERROR_SERIAL_REVOKE_COUNT, "4094 序列号吊销次数限制"),
    (ERROR_CERT_EXPIRE, "4095 无效证书"),
    (ERROR_MACHINE_INFO_INVALID, "4096 无效机器信息"),
    (ERROR_CERT_RENEWAL_TIME, "4097 未到续期时间"),
    (ERROR_RAW_MACHINE_INFO_PARSE_FAIL, "4098 原始机器信息解析失败"),
    (ERROR_TRAIN_MODEL_NOT_FOUND, "4099 未找到此店铺下的训练模型文件"),
    (ERROR_TS_GENERATE_FAIL, "4100 TS文件生成失败"),
    (ERROR_CERT_GENERATE_FAIL, "4101 证书生成失败, 请检查机器码"),
    (ERROR_CERT_RENEWAL_FAIL, "4102 证书续期失败, 请检查机器码"),
    (ERROR_SERIAL_DISABLE, "4103 序列号吊销次数过多导致禁用"),
    (ERROR_SERIAL_DECRY_FAILED, "4104 序列号解密失败"),
    (ERROR_SERIAL_BATCH_NOT_FOUND, "4105 未找到对应的序列号批次"),
    (ERROR_SERIAL_DEVICE_NOT_FOUND, "4106 查询不到对应的设备-序列号关联数据"),
    (ERROR_DEVICE_SERVICE_NOT_EXPIRE, "4107 设备服务未到期, 无法再次激活, 请走续期接口"),
    (ERROR_RESELLER_FORBIDDEN, "4108 经销商被禁用")
)

# 序列号状态
SERIAL_STATUS_WAITING_ACTIVATE = 0  # 待激活
SERIAL_STATUS_ACTIVATED = 1  # 已激活
SERIAL_STATUS_REVOKE = 2  # 已吊销

SERIAL_STATUS_TABLE = Choices(
    (SERIAL_STATUS_WAITING_ACTIVATE, "0 待激活"),
    (SERIAL_STATUS_ACTIVATED, "1 已激活"),
    (SERIAL_STATUS_REVOKE, "2 已吊销"),
)

# ts证书状态
TS_STATUS_WAITING_GENERATE = 0  # 待生成
TS_STATUS_GENERATED = 1  # 已生成

# 一些常量配置
SERIAL_ACTIVE_COUNT_MAX = 3  # 最大序列号激活次数

# 经销商状态
RESELLER_STATUS_NORMAL = 1  # 正常
RESELLER_STATUS_FORBIDDEN = 0  # 禁用
